# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module(
    name = "cel_java",
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "protobuf", version = "29.3", repo_name = "com_google_protobuf")  # see https://github.com/bazelbuild/rules_android/issues/373
bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33.bcr.1", repo_name = "com_google_googleapis")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_java", version = "8.12.0")
bazel_dep(name = "rules_android", version = "0.6.4")
bazel_dep(name = "rules_shell", version = "0.5.1")
bazel_dep(name = "googleapis-java", version = "1.0.0")
bazel_dep(name = "cel-spec", version = "0.24.0", repo_name = "cel_spec")

switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages(java = True)
use_repo(switched_rules, "com_google_googleapis_imports")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")

GUAVA_VERSION = "33.4.8"

TRUTH_VERSION = "1.4.4"

# Compile only artifacts
[
    maven.artifact(
        artifact = artifact,
        group = group,
        neverlink = True,
        version = version,
    )
    for group, artifact, version in [coord.split(":") for coord in [
        "com.google.code.findbugs:annotations:3.0.1",
        "com.google.errorprone:error_prone_annotations:2.38.0",
    ]]
]

# Test only artifacts
[
    maven.artifact(
        testonly = True,
        artifact = artifact,
        group = group,
        version = version,
    )
    for group, artifact, version in [coord.split(":") for coord in [
        "org.mockito:mockito-core:4.11.0",
        "io.github.classgraph:classgraph:4.8.179",
        "com.google.testparameterinjector:test-parameter-injector:1.18",
        "com.google.guava:guava-testlib:" + GUAVA_VERSION + "-jre",
        "com.google.truth.extensions:truth-java8-extension:" + TRUTH_VERSION,
        "com.google.truth.extensions:truth-proto-extension:" + TRUTH_VERSION,
        "com.google.truth.extensions:truth-liteproto-extension:" + TRUTH_VERSION,
        "com.google.truth:truth:" + TRUTH_VERSION,
    ]]
]

maven.install(
    name = "maven",
    # keep sorted
    artifacts = [
        "com.google.auto.value:auto-value:1.11.0",
        "com.google.auto.value:auto-value-annotations:1.11.0",
        "com.google.guava:guava:" + GUAVA_VERSION + "-jre",
        "com.google.protobuf:protobuf-java:4.31.0",
        "com.google.protobuf:protobuf-java-util:4.31.0",
        "com.google.re2j:re2j:1.8",
        "info.picocli:picocli:4.7.7",
        "org.antlr:antlr4-runtime:4.13.2",
        "org.freemarker:freemarker:2.3.34",
        "org.jspecify:jspecify:1.0.0",
        "org.threeten:threeten-extra:1.8.0",
        "org.yaml:snakeyaml:2.4",
    ],
    repositories = [
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
    ],
)
maven.install(
    name = "maven_android",
    # keep sorted
    artifacts = [
        "com.google.guava:guava:" + GUAVA_VERSION + "-android",
        "com.google.protobuf:protobuf-javalite:4.31.0",
    ],
    repositories = [
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
    ],
)

# Conformance test only

maven.install(
    name = "maven_conformance",
    artifacts = ["dev.cel:cel:0.11.0-SNAPSHOT"],
    repositories = [
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
        "https://central.sonatype.com/repository/maven-snapshots/",
    ],
)
use_repo(maven, "maven", "maven_android", "maven_conformance")

non_module_dependencies = use_extension("//:repositories.bzl", "non_module_dependencies")
use_repo(non_module_dependencies, "antlr4_jar")
use_repo(non_module_dependencies, "bazel_common")
